/**
 * 
 */
package com.agilegroup.crm.ui.fragments;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockDialogFragment;
import com.agilegroup.crm.AgileApplication;
import com.agilegroup.crm.R;

/**
 * @author Hisham
 *
 */
public class ExitDialogFragment extends SherlockDialogFragment{

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dialog_exit_txt)
               .setPositiveButton(R.string.dialog_exit_yes, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                      getSherlockActivity().finish();
                      if(AgileApplication.getInstance().spiceManager.isStarted()){
              			AgileApplication.getInstance().spiceManager.shouldStop();
              		}
                   }
               })
               .setNegativeButton(R.string.dialog_exit_no, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                     dialog.dismiss();
                   }
               });
        return builder.create();
	}
}
